package com.ruoyi.system.service.impl;

import java.io.InputStream;
import java.util.Date;
import java.util.List;

import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.BiogasDispatchingDataMapper;
import com.ruoyi.system.domain.BiogasDispatchingData;
import com.ruoyi.system.service.IBiogasDispatchingDataService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-09-25
 */
@Service
public class BiogasDispatchingDataServiceImpl implements IBiogasDispatchingDataService 
{
    @Autowired
    private BiogasDispatchingDataMapper biogasDispatchingDataMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param id 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public BiogasDispatchingData selectBiogasDispatchingDataById(Long id)
    {
        return biogasDispatchingDataMapper.selectBiogasDispatchingDataById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param biogasDispatchingData 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<BiogasDispatchingData> selectBiogasDispatchingDataList(BiogasDispatchingData biogasDispatchingData)
    {
        return biogasDispatchingDataMapper.selectBiogasDispatchingDataList(biogasDispatchingData);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param biogasDispatchingData 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertBiogasDispatchingData(BiogasDispatchingData biogasDispatchingData)
    {
        return biogasDispatchingDataMapper.insertBiogasDispatchingData(biogasDispatchingData);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param biogasDispatchingData 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateBiogasDispatchingData(BiogasDispatchingData biogasDispatchingData)
    {
        return biogasDispatchingDataMapper.updateBiogasDispatchingData(biogasDispatchingData);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param ids 需要删除的【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteBiogasDispatchingDataByIds(Long[] ids)
    {
        return biogasDispatchingDataMapper.deleteBiogasDispatchingDataByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param id 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteBiogasDispatchingDataById(Long id)
    {
        return biogasDispatchingDataMapper.deleteBiogasDispatchingDataById(id);
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void handleImportExcel(String fileName,InputStream inputStream) throws Exception {
        ExcelUtil<BiogasDispatchingData> excel=new ExcelUtil<BiogasDispatchingData>(BiogasDispatchingData.class);
        List<BiogasDispatchingData> biogasDispatchingDatas = excel.importExcel(inputStream);
        for (BiogasDispatchingData biogasDispatchingData : biogasDispatchingDatas
             ) {
            biogasDispatchingData.setCreateDate(new Date());
            biogasDispatchingDataMapper.insertBiogasDispatchingData(biogasDispatchingData);
        }
    }
}
